package com.lehecai.core.lottery.fetcher.lotterydraw.impl;

import com.lehecai.core.lottery.LotteryType;
import com.lehecai.core.lottery.fetcher.FetcherType;
import com.lehecai.core.lottery.fetcher.lotterydraw.LotteryDraw;
import com.lehecai.core.lottery.fetcher.lotterydraw.impl.worker.AbstractLotteryDrawFetchWorker;
import com.lehecai.core.lottery.fetcher.lotterydraw.impl.worker.LotteryDrawFetch543Worker163;
import com.lehecai.core.lottery.fetcher.lotterydraw.impl.worker.LotteryDrawFetch543WorkerOfficial;
import com.lehecai.core.lottery.fetcher.lotterydraw.impl.worker.LotteryDrawFetch543WorkerQihoo;
import com.lehecai.core.util.CoreFetcherUtils;

public class LotteryDrawFetcher543 extends BaseLotteryDrawFetcher {

	private static final LotteryType lotteryType = LotteryType.BJKL8;
	
	protected LotteryDraw fetchOfficial(String phase) {
		
		AbstractLotteryDrawFetchWorker fetchWorker = new LotteryDrawFetch543WorkerOfficial(lotteryType);
		
		LotteryDraw resultListObj = fetchWorker.fetchResult(phase);
		LotteryDraw resultDetailObj = fetchWorker.fetchResultDetail(phase);
		
		LotteryDraw returnObj = CoreFetcherUtils.getComparedResult(resultListObj, resultDetailObj);
		
		return returnObj;
	}
	
	protected LotteryDraw fetchQihoo(String phase) {
		AbstractLotteryDrawFetchWorker fetchWorker = new LotteryDrawFetch543WorkerQihoo(lotteryType);
		LotteryDraw resultListObj = fetchWorker.fetchResult(phase);
		LotteryDraw resultDetailObj = fetchWorker.fetchResultDetail(phase);
		LotteryDraw returnObj = CoreFetcherUtils.getComparedResult(resultListObj, resultDetailObj);
		return returnObj;
	}

    protected LotteryDraw fetch163(String phase) {
        AbstractLotteryDrawFetchWorker fetchWorker = new LotteryDrawFetch543Worker163(lotteryType);
        LotteryDraw resultListObj = fetchWorker.fetchResult(phase);
        LotteryDraw resultDetailObj = fetchWorker.fetchResultDetail(phase);
        //如果传入的彩期没取得详情开奖信息 则提示未抓取成功
        if (resultDetailObj == null) {
            return null;
        }
        LotteryDraw returnObj = CoreFetcherUtils.getComparedResult(resultListObj, resultDetailObj);
        return returnObj;
    }

	@Override
	protected FetcherType getDefaultFetcherType() {
		return FetcherType.T_OFFICIAL;
	}
}
